package org.advanced.generic;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author John.zhang
 * @version Id: ArrayLists, v 1.0 2020/12/3 16:23 ZhiYong Exp $
 */
public class ArrayLists {

    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        List<String> arrayList = new ArrayList();

        //运行阶段泛型是不会产生编译错误的效果
        Class<? extends List> aClass = arrayList.getClass();
        Method method = aClass.getDeclaredMethod("add", Object.class);
        method.invoke(arrayList, new Object());
        method.invoke(arrayList, 1);
        System.out.println(arrayList);
    }

}
